package cn.cdutetc.servlet;

import jdk.nashorn.api.scripting.NashornScriptEngineFactory;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
//@WebServlet(name = "testServlet",value="/demo1",loadOnStartup = 1)
public class testServlet  extends HttpServlet {
    @Override
    public void init() throws  ServletException{
        System.out.println("CNMCCN...");
        super.init();
    }

    @Override
    public void init(ServletConfig config) throws ServletException{
//        count = Integer.parseInt(config.getInitParameter("count"));
        super.init(config);
    }
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String user = req.getParameter("username");
       String pwd = req.getParameter("password");
        String[] hobbies = req.getParameterValues("hobby");
        resp.setContentType("text/html;charset=utf-8");

        PrintWriter writer = resp.getWriter();
        System.out.println("cnm........");
        for (String hobby:hobbies){
            System.out.println(hobby);
        }
    //参数传递


    //重定向


    //转发

    }

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
    @Override
    public void destroy(){
        System.out.println("cnmdmq");
//        super.destroy();
    }
}
